<?php
class lapbankcontroller extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper('form');
		$this->load->library('form_validation');
		$this->load->model('lapbank_model');
	}
	
	function index(){
		if (isset($_POST['btnview']))
		{
			$pilih = trim($_POST['choose']);
			$tglawal = trim($_POST['tglawal']);
			$tglakhr = trim($_POST['tglakhir']);
		}else{
			
			$pilih = "";
			$tglawal = "";
			$tglakhr = "";
		}
		
		if ($pilih=="G")
		{
			$data = $this->lapbank_model->getMutasigiro($tglawal,$tglakhr);
		}else{
			$data = $this->lapbank_model->getMutasibank($tglawal,$tglakhr);
		}
		
		$dataprofile = array(
				'page_title' => 'Laporan > Bank',
				'name' => $this->session->userdata('fullname'),
				'data' => $data,
				'tglAwal' => $tglawal,
				'tglAkhir' => $tglakhr,
				'chose' => $pilih
		);		
		$content = array(
		  'content' => 'laporan/lapbank'
		);
		$this->template->load('templates/default',$content,$dataprofile);
	}
	
	function toExcel()
	{
		if ($_REQUEST['choosed']=="G")
		{
			$data = $this->lapbank_model->getMutasigiro($_REQUEST['tglAwal'],$_REQUEST['tglAkhir']);
		}else{
			$data = $this->lapbank_model->getMutasibank($_REQUEST['tglAwal'],$_REQUEST['tglAkhir']);
		}
		$dataprofile = array
			(
				'page_title' => '',
				'name' => '',
				'data' => $data
			);			

		$this->load->view('laporan/excelbank',$dataprofile);
	}
}